package com.tanhua.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.mapper.AnnouncementsMapper;
import com.tanhua.sso.pojo.Announcement;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class AnnouncementsServiceApiImpi implements AnnouncementsServiceApi{

    @Autowired
    private AnnouncementsMapper announcementsMapper;

    @Override
    public Page<Announcement> getAnnouncements(Integer page, Integer pagesize) {
        Page<Announcement> announcementPage=new Page<>(page,pagesize);
        LambdaQueryWrapper<Announcement> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        lambdaQueryWrapper.orderByDesc(Announcement::getCreated);
        Page<Announcement> selectPage = announcementsMapper.selectPage(announcementPage, lambdaQueryWrapper);
        return selectPage;
    }
}
